import Layout from '@/views/layout/Layout';

// 控制这系列页面的权限
const authData = {
  customer: ['crm:customer:read'], // 销售客户
  customerAdjustment: ['crm:customerAdjustment:read'], // 客户调额申请
  customersettle: ['crm:customer:customerSettle'], // 客户结算
  mengliCustomer: ['mengli:customer:read', 'mengli:customer:admin'], // 萌力客户,
  returnedMoney: ['crm:return:read', 'crm:return:admin'], // 回款报表
  customerBill: ['crm:customerBill:read'] // 客户账单
};
let pageAllAuth = [];
for (const key in authData) {
  pageAllAuth = pageAllAuth.concat(authData[key]);
}

// 客户
const cilentRouter = [{
  path: '/client',
  component: Layout,
  redirect: '/client/customer',
  name: 'clientPage',
  meta: { title: '客户', authControl: pageAllAuth, icon: 'sidebar-client' },
  children: [
    {
      path: 'customer',
      name: 'customer',
      component: () => import('@/views/customer/index'),
      meta: { title: '销售客户', authControl: authData.customer, keepAlive: true, isChange: true, headerBarShow: false }
    },
    {
      path: 'cooperation',
      name: 'cooperation',
      component: () => import('@/views/customer/cooperation/list'),
      meta: { title: '客户协作申请', authControl: authData.customer, keepAlive: false, headerBarShow: false }
    },
    {
      path: 'customerAdjustment',
      name: 'customerAdjustment',
      component: () => import('@/views/customerAdjustment/index'),
      meta: { title: '客户调额申请', authControl: authData.customerAdjustment, keepAlive: false, isChange: true, headerBarShow: false }
    },
    {
      path: 'contact',
      name: 'contact',
      hidden: true,
      component: () => import('@/views/customer/contact/index'),
      meta: { title: '联系人明细', keepAlive: true, isChange: true, headerBarShow: false, activeMenu: '/client/customer' }
    },
    {
      path: 'mengliCustomer',
      name: 'mengliCustomer',
      component: () => import('@/views/mengliPlanet/customer/index'),
      meta: { keepAlive: true, isChange: true, title: '萌力客户', headerBarShow: false, authControl: authData.mengliCustomer }
    },
    {
      path: 'customersettlelist',
      name: 'customersettle',
      component: () => import('@/views/customer/settlelist'),
      meta: { authControl: authData.customersettle, keepAlive: true, isChange: true, title: '客户结算', headerBarShow: false }
    },
    {
      path: 'returnedMoney',
      name: 'returnedMoney',
      component: () => import('@/views/returnedMoney/index'),
      meta: { authControl: authData.returnedMoney, keepAlive: true, isChange: true, title: '回款报表', headerBarShow: true }
    },
    {
      path: 'customerBill',
      name: 'customerBill',
      component: () => import('@/views/customerBill/index'),
      meta: { authControl: authData.customerBill, keepAlive: true, isChange: true, title: '客户账单', headerBarShow: true }
    },
    /**
     * 内页
     */
    /** 销售客户内页 */
    {
      path: 'customerdetail/:customerId',
      component: () => import('@/views/customer/detail/index'),
      name: 'detailCustomer',
      meta: { title: '客户详情', isContact: false, isSeal: false, keepAlive: false, isChange: true, headerBarShow: true, activeMenu: '/client/customer' },
      hidden: true
    },
    {
      path: 'customersettle/:id',
      component: () => import('@/views/customer/settleDetail'),
      name: 'settleCustomer',
      meta: { title: '客户结算详情', isContact: false, isSeal: false, keepAlive: false, headerBarShow: true, activeMenu: '/client/customersettlelist' },
      hidden: true
    },
    {
      path: 'customercreate',
      component: () => import('@/views/customer/create/index'),
      name: 'createCustomer',
      meta: { title: '新增客户', isContact: false, isSeal: false, keepAlive: false, headerBarShow: true, activeMenu: '/client/customer' },
      hidden: true
    },
    {
      path: 'customeredit/:customerId',
      component: () => import('@/views/customer/create/index'),
      name: 'editCustomer',
      meta: { title: '编辑客户', isContact: false, isSeal: false, keepAlive: false, headerBarShow: true, activeMenu: '/client/customer' },
      hidden: true
    },
    {
      path: 'customerAdjustmentDetail',
      component: () => import('@/views/customerAdjustment/detail/index'),
      name: 'customerAdjustmentDetail',
      meta: { title: '客户调额申请详情', isContact: false, isSeal: false, keepAlive: false, isChange: true, headerBarShow: true, activeMenu: '/client/customerAdjustment' },
      hidden: true
    },
    {
      path: 'customerAdjustmentCreate',
      component: () => import('@/views/customerAdjustment/create/index'),
      name: 'customerAdjustmentCreate',
      meta: { title: '客户调额申请', isContact: false, isSeal: false, keepAlive: false, headerBarShow: true, activeMenu: '/client/customerAdjustment' },
      hidden: true
    },
    {
      path: 'customerAdjustmentEdit/:id',
      component: () => import('@/views/customerAdjustment/create/index'),
      name: 'customerAdjustmentEdit',
      meta: { title: '客户调额申请', isContact: false, isSeal: false, keepAlive: false, headerBarShow: true, activeMenu: '/client/customerAdjustment' },
      hidden: true
    },
    /** 萌力客户内页 */
    {
      path: 'mengliDetail/:customerId',
      component: () => import('@/views/mengliPlanet/customer/detail/index'),
      name: 'mengliCustomerDetail',
      meta: { title: '客户详情', keepAlive: false, headerBarShow: true, activeMenu: '/client/mengliCustomer' },
      hidden: true
    },
    {
      path: 'editMengliCustomer/:customerId',
      component: () => import('@/views/mengliPlanet/customer/create/index'),
      name: 'editMengliCustomer',
      meta: { title: '编辑客户', keepAlive: false, headerBarShow: true, activeMenu: '/client/mengliCustomer' },
      hidden: true
    },
    {
      path: 'createMengliCustomer',
      component: () => import('@/views/mengliPlanet/customer/create/index'),
      name: 'createMengliCustomer',
      meta: { title: '新增客户', keepAlive: false, headerBarShow: true, activeMenu: '/client/mengliCustomer' },
      hidden: true
    },
    {
      path: 'customerBillDetail/:id',
      component: () => import('@/views/customerBill/detail'),
      name: 'detailCustomerBill',
      meta: { title: '账单详情', isChange: true, headerBarShow: true, activeMenu: '/client/customerBill' },
      hidden: true
    },
    /** 回款报表内页 */
    {
      path: 'returnedMoney/:returnId',
      component: () => import('@/views/returnedMoney/detail/index'),
      name: 'paymentReceived',
      meta: { title: '回款报表详情', keepAlive: false, headerBarShow: false, activeMenu: '/client/returnedMoney' },
      hidden: true
    }
  ]
}];
export default cilentRouter;
